module namespace iatistoring="http://iatiui.ampdev.net/iatistoring";

import module namespace  xmldb="http://exist-db.org/xquery/xmldb";

declare variable $iatistoring:CACHE_PATH := "/iAG/cache";

declare function iatistoring:write_cache($filename as xs:string, $content as node() ) as xs:string {

	let $exists := xmldb:collection-available("/iAG/cache"),
	$isLoggedIn := xmldb:login("xmldb:exist:///db", "exuser", "1at1")
	return
	if ( $exists ) then
	   xmldb:store($iatistoring:CACHE_PATH,$filename,$content)
	else 
	  let $out := xmldb:create-collection("/iAG","cache")
	  return xmldb:store($iatistoring:CACHE_PATH,$filename,$content)
};